Get which-key--buffer's window from any frame
authorJonas Bernoulli <jonas@bernoul.li>
Sun, 30 May 2021 18:39:55 +0000 (20:39 +0200)
committerJonas Bernoulli <jonas@bernoul.li>
Sun, 30 May 2021 19:32:50 +0000 (21:32 +0200)
Previously we assumed the buffer was being displayed in a window
of the current frame, which isn't the case if e.g. a child frame
is being used.

We also cannot assume that the third-party code that sets up such
a child frame also deletes it.  `which-key-posframe' for example
merely hides it.

which-key.el

index 3f5f8097cd16ad45f3a9a0a4355d40aa61242234..74accfa3383d69887ad036195becd16bcb7e33c6 100644 (file)
@@ -1175,7 +1175,10 @@ popup)."
 
 (defun which-key--popup-showing-p ()
   (and (bufferp which-key--buffer)
-       (window-live-p (get-buffer-window which-key--buffer))))
+       (or (window-live-p (get-buffer-window which-key--buffer))
+          (let ((window (get-buffer-window which-key--buffer t)))
+            (and (window-live-p window)
+                 (frame-visible-p (window-frame window)))))))
 
 (defun which-key--show-popup (act-popup-dim)
   "Show the which-key buffer.